﻿using UnityEngine;
using System.Collections;

public class Flag : MonoBehaviour {

	public Offense owner;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter(Collider other) {

		if(other.tag == "Offense"){
            if (owner == null) {
                CTFGameManager.Instance.TakeFlag();
            }
			if(owner!=null){
				owner.hasFlag = false;
			}

			other.GetComponent<Offense>().hasFlag = true;
			transform.parent = other.transform;
			owner = other.GetComponent<Offense>();
		}
	}

}
